<?php
define('ROOT_DIR', $_SERVER['DOCUMENT_ROOT'].'/');
$path = ROOT_DIR.'setting.php';
$settingsContent = file_get_contents($path);
$titles = $_POST['title'];
$admins = $_POST['admin'];
$visitors = (int)$_POST['visitor'];
$visitors2 = (int)$_POST['visitor2'];
$setting_dexs_array = <<<EOT
\$website_array = array(
    'admin' => '$titles',
    'quascode' => '$admins',
    'notlogined'=> $visitors,
    'notlogined2'=>$visitors2
);
EOT;
$pattern = '/\$website_array\s*=\s*array\s*\(\s*[^;]*\s*\);/s';
$replacement = $setting_dexs_array;
$updatedSettingsContent = preg_replace($pattern, $replacement, $settingsContent);
file_put_contents($path, $updatedSettingsContent);
echo '<script>alert("修改成功");window.location.href="../../pzsetting.php?s=personal";</script>';